﻿<%@ WebHandler Language="C#" Class="Product_GetByPage" %>

using System;
using System.Web;
using System.Text;
using Newtonsoft.Json;
public class Product_GetByPage : IHttpHandler, System.Web.SessionState.IReadOnlySessionState
{
    
    public void ProcessRequest (HttpContext context) 
    {
        OTS.Common.Page<OTS.Model.Product> page = new OTS.Common.Page<OTS.Model.Product>();
        if (!OTS.BaseLogin.validataModule(context, (int)OTS.enumSysRight.ProductManager))
        {
            page.success = false;
            page.msg = "非法操作！";
        }
        else
        {
            string limit = context.Request["limit"];
            string start = context.Request["start"];
            string proName = context.Request["proName"];
            string proNO = context.Request["proNO"];
 
            int limitInt = 20;
            int startInt = 0;
            if (null != limit && OTS.Common.Help.IsNumber(limit)) limitInt = int.Parse(limit);
            if (null != start && OTS.Common.Help.IsNumber(start)) startInt = int.Parse(start);
            if (null == proName) proName = "";
            if (null == proNO) proNO = "";
            
            OTS.BLL.ProductBLL bll = new OTS.BLL.ProductBLL();
            string strWhere = "";
            if (proName.Trim() != "" || proNO.Trim() != "")
            {
                strWhere = " 1=1 ";
            }
            if (proName.Trim() != "")
            {
                strWhere += " AND proName like '%" + OTS.Common.SqlStringFormat.GetString(proName) + "%' ";                 
                
            }
            if (proNO.Trim() != "")
            {
                strWhere += " AND proNO like '%" + OTS.Common.SqlStringFormat.GetString(proNO) + "%' ";
            }
            page = bll.GetListByPage(startInt, limitInt, strWhere);




        } 
        context.Response.ContentType = "application/x-json";
        context.Response.Charset = "utf-8";
        context.Response.Write(JavaScriptConvert.SerializeObject(page));
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}